#pragma once

#include <gtest/gtest.h>

template <class T>
struct CRUDTest : public ::testing::Test
{
};
TYPED_TEST_CASE_P(CRUDTest);

TYPED_TEST_P(CRUDTest, inv_query)
{
	TypeParam type;
    ASSERT_THROW(type.query(), std::exception);
}
TYPED_TEST_P(CRUDTest, CRD)
{
	TypeParam type;
    ASSERT_THROW(type.query(), std::exception);

	type.insert();
	auto q1 = type.query();
	ASSERT_TRUE(type.checkInsert(q1));

    type.remove();
    ASSERT_THROW(type.query(), std::exception);
}

TYPED_TEST_P(CRUDTest, CRUD)
{
	TypeParam type;
    ASSERT_THROW(type.query(), std::exception);

	type.insert();
	auto q1 = type.query();
	ASSERT_TRUE(type.checkInsert(q1));

    type.update();
	auto q2 = type.query();
	ASSERT_TRUE(type.checkInsert(q2));

    type.remove();
    ASSERT_THROW(type.query(), std::exception);
}

REGISTER_TYPED_TEST_CASE_P(CRUDTest, inv_query, CRD, CRUD);